C     Program EX_0403.FOR
C     Listing 7F - see documentation in TUTOR.SSS
 
$include:'SSSF1.H'
 
      subroutine prime
$include:'SSSF2.H'
      integer ARRIVL, STARTA, ENDACT
      real*8 c
      common ARRIVL, STARTA, ENDACT, c
      real*8 endt
      data endt /40.0/
 
      ARRIVL = 1
      STARTA = 2
      ENDACT = 3
      c      = 0.0
 
      call INIQUE(0, 0, 1)
      call inista(1,'Occupancy            ',1,0,0.0,0.0)
      call SIMEND(endt)
      call CREATE(0.0, 0)
      call TALLY(1, c)
      return
      end
 
      subroutine leavec
$include:'SSSF2.H'
      integer ARRIVL, STARTA, ENDACT
      real*8 c
      common ARRIVL, STARTA, ENDACT, c
 
      c = c + 1.0
      call TALLY(1, c)
      call SCHED(EX(20), ENDACT, 0)
      call DISPOS
      return
      end
 
      subroutine pickc
$include:'SSSF2.H'
      integer ARRIVL, STARTA, ENDACT
      real*8 c
      common ARRIVL, STARTA, ENDACT, c
 
      c = c - 1.0
      call TALLY(1, c)
      call DISPOS
      return
      end
 
      Program EX_0401
$include:'SSSF2.H'
      integer ARRIVL, STARTA, ENDACT
      real*8 c
      common ARRIVL, STARTA, ENDACT, c
      integer ecode
 
      call prime
 
   99 ecode = NEXTEV()
      if (ecode.gt.0) then
        goto(101, 102, 103) ecode
 
C ARRIVL
  101   continue
        call CREATE(EX(2.0), 0)
        call SCHED(0.0, STARTA, 0)
        goto 99
 
C STARTA
  102   continue
        call leavec
        goto 99
 
C ENDACT
  103   continue
        call pickc
        goto 99
 
      else
 
        call SUMRY(' ')
        stop 'End of simulation'
 
      endif
      end
